﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>部门新增</title>
    </head>
    <body>
    <form class="layui-form" action="" method="post">
    <div class="layui-col-md6">
        <div class="layui-form-item">
            <label class="layui-form-label">部门编号</label>
            <div class="layui-input-block">
                <input type="text" name="DepartmentNo" lay-verify="required" placeholder="部门编号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">企业名称</label>
            <div class="layui-input-block">
                    <select id="LevelName">
                        <option value="请选择">请选择</option>
                        <option value="爱吃兔">爱吃兔</option>
                        <option value="六个核弹">六个核弹</option>
                        <option value="六个核桃">六个核桃</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部门名称</label>
            <div class="layui-input-block">
                <input type="text" name="DepartmentName" lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部门类型</label>
            <div class="layui-input-block">
                    <select id="TypeName">
                        <option value="请选择">请选择</option>
                        <option value="企划部">企划部</option>
                        <option value="销售部">销售部</option>
                        <option value="财务部">财务部</option>
                </select>
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">区域</label>
                <div class="layui-input-block">
                    <select id="AreaName">
                        <option value="请选择">请选择</option>
                        <option value="河北">河北</option>
                        <option value="四川">四川</option>
                        <option value="北京">北京</option>
                    </select>
                </div>
            </div>
              <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
          
    </form>
    </div>
    </body>
</html>
<script>

    layui.use(['form', 'laydate', 'util'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 提交事件
        form.on('submit(demo1)', function (data) {
            var field = data.field; // 获取表单字段值
            field.State = 0;
            
            let obj = {
                departmentid: 0,
                levelName: $("#LevelName").val(),
                departmentName: $("[name='DepartmentName']").val(),
                typeName: $("#TypeName").val() ,
                isNo: 0,
                departmentNo: $("[name='DepartmentNo']").val(),
                areaName: $("#AreaName").val()
            }
            console.log(obj);
            $.ajax({
                url: '@ViewBag.FoundationWrite'+ "/api/Jocker/DepartmentsAdd",
                data: JSON.stringify(obj),
                type: "post",
                contentType: "application/json",
                success: function (res) {

                    console.log(res);
                    if (res > 0) {
                        layer.alert("添加成功", {
                            title: ''
                        });
                    }
                    else {
                        alert('提交失败')
                    }
                }
            })

            return false;
        });
    });






</script>